CitiesController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 23
dl 0
loc 26
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Functions

Rating   Name   Duplication   Size   Complexity  
A createACity 0 10 1
A getAllCities 0 10 1
1 8
import { Body, Controller, Get, Post } from '@nestjs/common';
2 8
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
3 8
import { CitiesService } from './cities.service';
4 8
import { CreateCityDto } from './dto/create-city.dto';
5 8
import { City } from './entities/city.entity';
6
7
@ApiTags('Cities')
8
@Controller({ path: 'cities', version: '1' })
9 8
export class CitiesController {
10 8
  constructor(private readonly citiesService: CitiesService) {}
11
12
  @Get()
13
  @ApiOperation({ summary: 'Get all cities' })
14
  @ApiResponse({
15
    status: 200,
16
    description: 'List of bicycles',
17
    type: [City],
18
  })
19 8
  async getAllCities() {
20 1
    return await this.citiesService.findAll();
21
  }
22
23
  @Post('create')
24
  @ApiOperation({ summary: 'Create a new city' })
25
  @ApiResponse({
26
    status: 201,
27
    description: 'City created successfully',
28
    type: City,
29
  })
30 8
  async createACity(@Body() createCityDto: CreateCityDto) {
31 1
    return await this.citiesService.createCity(createCityDto);
32
  }
33
}
34